home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / code_1.zip / TEM_MNTC.PRG < prev    next >
Text File  |  1989-01-03  |  12KB  |  376 lines

  1. * ________.PRG
  2. * ________________________________ FILE MAINTENANCE by _________________
  3. *     created: __/__/__
  4. * last update: __/__/__
  5. *
  6. ****************************************************
  7. * NOTE:  All procedures called in this program are *
  8. *        at the bottom of this program.            *
  9. *                                                  *
  10. *        All UDFs (usually prefixed with c_) are   *
  11. *        located in the TEM_UDFS.PRG program file. *
  12. ****************************************************
  13. *
  14. *****************************************
  15. * HELP key Initialization (if required) *
  16. *****************************************
  17. * SET KEY 28 TO MNTCHELP
  18. *
  19. ********************************************
  20. * MESSAGE line intialization (if required) *
  21. ********************************************
  22. * SET MESSAGE TO 2
  23. *
  24. ****************************
  25. * Open required data files *
  26. ****************************
  27.  
  28.  
  29. *
  30. ***************************************************
  31. * Establish Relations between files (if required) *
  32. ***************************************************
  33.  
  34.  
  35.  
  36. *
  37. **************************************************
  38. * Create memory variables to be accessed by the  *
  39. * UDFs c_MEMEMPTY(), c_SCATTER(), c_GATHER() and *
  40. * c_BLANK().                                     *
  41. **************************************************
  42. FOR memctr  = 1 TO FCOUNT()
  43.     memvar  = "M"+FIELDNAME(memctr)
  44.    &memvar. = .T.
  45. NEXT
  46.  
  47. *
  48. **********************
  49. * Display the screen *
  50. **********************
  51. CLEAR
  52. morder="________"                        &&  Master Index Order (if applicable)
  53. @ __,__ GET morder
  54. CLEAR GETS
  55.  
  56. * @ 03,00 SAY REPLICATE(CHR(196),79)      &&  Single Top Border Line ala LOTUS
  57. * @ 23,00 SAY REPLICATE(CHR(196),79)      &&  Block Bottom Border Line ala LOTUS
  58.  
  59.  
  60. *
  61.  
  62. **********************
  63. * Display the record *
  64. **********************
  65. mrecno=RECNO()               && Mark position in file
  66. DO ____DISP
  67. *
  68. DO WHILE .T.
  69.    *
  70.    c_MTC_MENU(1,00)          && UDF to display Maintenance Menu (see TEM_UDFS.PRG)
  71.    *
  72.    DO CASE
  73.       CASE mmopt=0
  74.          EXIT
  75.          *
  76.       CASE mmopt=1
  77.          ****************
  78.          * ADD a record *
  79.          ****************
  80.          SET CURSOR ON
  81.          DO WHILE .T.
  82.             c_MEMEMPTY()     && Initialize memory variables UDF
  83.  
  84.             DO ____GETS                && GET routine to clear variables on screen
  85.             CLEAR GETS
  86.             @ 24,40-(LEN(mmsg)/2) SAY mmsg
  87.             *
  88.             ********************
  89.             * Get KEY field(s) *
  90.             ********************
  91.             @ __,__ GET ________
  92.  
  93.             READ
  94.             CLEAR GETS
  95.             IF LASTKEY()=27 .OR. EMPTY(________)
  96.                **************************************************
  97.                * ESCape was pressed or no input on key field(s) *
  98.                **************************************************
  99.                IF RECCOUNT()<>0
  100.                   GOTO mrecno          &&  Reset record pointer
  101.                ENDIF
  102.                EXIT
  103.             ENDIF
  104.             mskey=________             &&  Initialize key variable (if multiple keys)
  105.             SEEK mskey
  106.             IF .NOT. EOF()
  107.                * Record already exists
  108.                EXIT
  109.             ENDIF
  110.             mmsg="Enter all required information or press ESCape when finished"
  111.             @ 24,0
  112.             @ 24,40-(LEN(mmsg)/2) SAY mmsg
  113.             *
  114.  
  115.             DO ____GETS                && GET routine to input variables
  116.             READ
  117.             CLEAR GETS
  118.             *
  119.             IF LASTKEY()<>27
  120.                ******************************************
  121.                * Continue if ESCape key was not pressed *
  122.                ******************************************
  123.                mreply="Y"
  124.                @ 24,0
  125.                @ 24,26 SAY "OKAY TO ADD RECORD (Y/N)?" GET mreply PICTURE "!" VALID(mreply$"YN")
  126.                READ
  127.                @ 24,0
  128.                IF mreply="Y"
  129.                   SEEK c_BLANK(________)     && Seek empty record (c_BLANK() is a UDF in system module)
  130.                   IF EOF()
  131.                      APPEND BLANK
  132.                   ENDIF
  133.                   ***********************************************************
  134.                   * Update fields with memory variables through REPLACE UDF *
  135.                   ***********************************************************
  136.                   c_GATHER()
  137.                   *
  138.                   mrecno=RECNO()            && Update record pointer
  139.                ELSE
  140.                   IF RECCOUNT()<>0
  141.                      GOTO mrecno            && Reposition record pointer
  142.                   ENDIF
  143.                ENDIF
  144.             ENDIF lastkey()<>27
  145.          ENDDO .t. (main ADD control loop)
  146.          *
  147.       CASE mmopt=2
  148.          *******************
  149.          * DELETE a record *
  150.          *******************
  151.          SET CURSOR ON
  152.          mreply="N"
  153.          @ 24,10 SAY "DELETE THIS RECORD (Y/N)?" GET mreply PICTURE "!" VALID(mreply$"YN")
  154.          READ
  155.          IF mreply="Y"
  156.             mreply="N"
  157.             @ 24,47 SAY "ARE YOU SURE (Y/N)?" GET mreply PICTURE "!" VALID(mreply$"YN")
  158.             READ
  159.             IF mreply="Y"
  160.                c_DATAGONE()                 && Replace fields with empty values UDF
  161.                GO TOP                       && Reposition record pointer
  162.             ENDIF
  163.          ENDIF
  164.          *
  165.       CASE mmopt=3
  166.          *****************
  167.          * EDIT a record *
  168.          *****************
  169.          SET CURSOR ON
  170.          *
  171.          c_SCATTER()         && Load memory variables with field values
  172.          *
  173.          mmsg="Enter changes or press ESCape when finished"
  174.          @ 24,0
  175.          @ 24,40-(LEN(mmsg)/2) SAY mmsg
  176.          *
  177.          DO ____GETS                   && GET routine to input variables
  178.          READ
  179.          CLEAR GETS
  180.          IF LASTKEY()<>27
  181.             **********************************************************
  182.             * If operator did not ESCape out of EDIT, perform memory *
  183.             * variables-to-fields UDF.                               *
  184.             **********************************************************
  185.             c_GATHER()
  186.          ENDIF
  187.          *
  188.       CASE mmopt=4
  189.          *********************
  190.          * GO to TOP of file *
  191.          *********************
  192.          GO TOP
  193.          *
  194.       CASE mmopt=5
  195.          *********************************************************
  196.          * GOTO SPECIFIED record. This routine uses system UDFs. *
  197.          *********************************************************
  198.          SET CURSOR ON
  199.          mscreen=SPACE(4000)
  200.          ****************************************
  201.          * Save the INDEX order (if applicable) *
  202.          ****************************************
  203.          mindex=INDEXORD()                       && Save the index order
  204.          SAVE SCREEN TO mscreen                  && Save the screen
  205.          c_BOXIT(18,13,23,65,1,c_goto_box)       && Save the whales (oops!)
  206.          c_SAYIT(19,16,"Consignee ID ........",c_goto_box)
  207.          c_SAYIT(20,16,"Name ................",c_goto_box)
  208.          c_SAYIT(22,16,"Enter Values for Search or ESCape when finished",c_goto_box)
  209.          *
  210.          DO WHILE .T.
  211.             *************************************
  212.             * Initialize key memory variable(s) *
  213.             *************************************
  214.  
  215.  
  216.             ******************************
  217.             * GET key memory variable(s) *
  218.             ******************************
  219.  
  220.  
  221.             READ
  222.             CLEAR GETS
  223.             *
  224.             IF LASTKEY()=27 .OR. EMPTY(________)
  225.                **************************************************
  226.                * ESCape was pressed or no input on key field(s) *
  227.                **************************************************
  228.                IF RECCOUNT()<>0
  229.                   GOTO mrecno          &&  Reset record pointer
  230.                ENDIF
  231.                SET ORDER TO mindex     &&  Reset master index
  232.